#include "const.h"

var_t v_new_array(const char *name, const char *ptrname, size_t initsize) {
	size_t i;
	var_t v;

	v = v_new(name);

	v->flags |= VAR_ARRAY_BIT;
	v->value.text = (char *)0;

	v->array.n = 0;

	if (initsize) {
		v->array.members = (char **)i_new(sizeof(char *)*initsize);

		for(i=0; i<initsize; i++)
			v->array.members[i] = (char *)0;

		v->array.capacity = initsize;
	}

	v->array.ptrvar = v_new(ptrname);

	v->array.ptrvar->flags |= VAR_SYMLINK_BIT;
	v->array.ptrvar->value.symlink = v;
	v->array.ptrvar->array.ptrvar = v;

	return v;
}
